package com.deyuanyun.pic.pipe.controller.vo.merge;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVO;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.domain.GwwDetection;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 环焊缝无损检测信息表
 */
public class GwwDetectionVO extends BaseVO<GwwDetection> {

    // 管道名称
    private String pipeLineName;
    // 环焊缝焊接编号
    private String gwwNum;
    // 无损检测类型
    private String ndtType;
    // 是否返修：0，否；1，是
    private String repairind;
    // 检测单位
    private String testingCompany;
    // 检测日期
    private String testDate;
    // 检测报告
    private String testingReport;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getGwwNum() {
        return gwwNum;
    }

    public void setGwwNum(String gwwNum) {
        this.gwwNum = gwwNum;
    }

    public String getNdtType() {
        return ndtType;
    }

    public void setNdtType(String ndtType) {
        this.ndtType = ndtType;
    }

    public String getRepairind() {
        return repairind;
    }

    public void setRepairind(String repairind) {
        this.repairind = repairind;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getTestDate() {
        return testDate;
    }

    public void setTestDate(String testDate) {
        this.testDate = testDate;
    }

    public String getTestingReport() {
        return testingReport;
    }

    public void setTestingReport(String testingReport) {
        this.testingReport = testingReport;
    }

    @Override
    public void fromDomain(GwwDetection domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 环焊缝焊接编号
        this.gwwNum = domain.getGwwId();
        // 无损检测类型
        this.ndtType = CodeUtil.getName(domain.getNdtType());
        // 是否返修：0，否；1，是
        this.repairind =  convert(domain.getRepairind());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();
        // 检测日期
        this.testDate = DateFormat.format(domain.getTestDate());
        // 检测报告
        this.testingReport = domain.getTestingReport();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getCreateRemark());
    }

    public List<GwwDetectionVO> fromDomainList(List<GwwDetection> domainList) {
        List<GwwDetectionVO> list = new ArrayList<GwwDetectionVO>();
        for (GwwDetection gwwDetection : domainList) {
            GwwDetectionVO gwwDetectionVO = new GwwDetectionVO();
            gwwDetectionVO.fromDomain(gwwDetection);
            list.add(gwwDetectionVO);
        }
        return list;
    }
}